import xlrd

data = xlrd.open_workbook('test.xlsx')
table = data.sheets()[0]
# 获取列表的有效列数
ncols = table.ncols
# print(ncols)

# 返回由该列中所有的单元格对象组成的列表
cols_val = table.col(0, start_rowx=0, end_rowx=None)
cols_val = table.col(1, start_rowx=0, end_rowx=None)
cols_val = table.col(2, start_rowx=0, end_rowx=None)
# print(cols_val)

# 循环获取
# for i in range(ncols):
#     cols_val = table.col(i, start_rowx=0, end_rowx=None)
#     print(cols_val)

 # 返回由该列中所有的单元格对象组成的列表
# for i in range(ncols):
#     cols_val = table.col_slice(i, start_rowx=0, end_rowx=None)
#     print(cols_val)

 # 返回由该列中所有单元格的数据组成的列表
# val = table.col_values(0, start_rowx=0, end_rowx=None)
# print(val)

for i in range(ncols):
    val = table.col_values(i, start_rowx=0, end_rowx=None)
    print(val)
